<template>
  <div class="dashboard-editor-container">
    <user-group/>
    <!--    <ProductData :isCommon="true"></ProductData>-->
    <!--    <notice/>-->
    <!--  系统公告和ERP消息  -->
    <div class="flex-between">
      <el-card class="box-card" style="width: 45%">
        <div slot="header" class="flex flex-between">
          <span>系统公告</span>
          <el-button type="text">
            更多
            <i class="el-icon-d-arrow-right"></i>
          </el-button>
        </div>
        <div v-for="o in 4" :key="o" class="text item">
          {{ '列表内容 ' + o }}
        </div>
      </el-card>
      <el-card class="box-card" style="width: 45%">
        <div slot="header" class="flex flex-between">
          <span>ERP消息</span>
          <el-button type="text"> 更多
            <i class="el-icon-d-arrow-right"></i>
          </el-button>
        </div>
        <div v-for="o in 4" :key="o" class="text item">
          {{ '列表内容 ' + o }}
        </div>
      </el-card>
    </div>
  </div>
</template>

<script>
import UserGroup from '../../dashboard/UserGroup'
import Notice from '../../dashboard/Notice'
import ProductData from "@/views/dataSearch/productData.vue";
import {
  reView,
  ErpSaleRankingMonthData, ckeckEmpowerStatus
} from "@/api/index/index"

export default {
  name: 'personPage',
  components: {
    UserGroup,
    Notice,
    ProductData
  },
  data() {
    return {
      tableData: [],
      weekData: {},
      spxsParams: {
        pageSize: 10,
        pageNum: 1
      },
      weekPayAmountData: {},
      monthCategoryData: [],
      monthCountryData: []
    }
  },
  created() {
    this.getReView();
    this.getErpSaleRankingMonthData();
    this.ckeckEmpowerStatus()
  },
  methods: {
    // 近一个月商品销售排行
    getErpSaleRankingMonthData() {
      ErpSaleRankingMonthData(this.spxsParams).then(res => {
        this.tableData = res.records;
      })
    },
    // 查看是否有未处理的订单
    getReView() {
      reView().then(res => {
        if (res.str == '1') {
          this.noticeFn();
        }
      })
    },
    // 查看是否有授权过期的店铺
    ckeckEmpowerStatus() {
      ckeckEmpowerStatus().then(res => {
        if (res.msg) {
          this.$confirm(res.msg, '提示', {
            confirmButtonText: '查看',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.$router.push(`/empower/shopList`);
          })
        }
      }).catch(err => {
        console.log('err', err)
      })
    },
    noticeFn() {
      this.$confirm('您有新的订单待处理', '提示', {
        confirmButtonText: '查看',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$router.push(`/order/order`);
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .chart-wrapper {
    background: #fff;
    padding: 20px 16px 0;
    margin-bottom: 32px;

    .chart-wrapper-box {
      padding-bottom: 20px;
    }

    p {
      font-size: 16px;
      line-height: 18px;
      margin: 0 0 15px;
      color: #666;
    }
  }

  .margin0 {
    margin: 0;
  }
}

@media (max-width: 1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
</style>
